<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">
    <!-- for in 或者for of 都可以 -->
    <!-- 可以遍历数组 -->
    <ul>
      <li v-for="(item, index) in arr">{{index}}: {{item}}</li>
    </ul>
    <!-- 可以遍历对象 -->
    <ul>
      <li v-for="(value, key) in obj">{{key}}: {{value}}</li>
    </ul>
    <!-- 可以遍历字符串 -->
    <ul>
      <li v-for="(char, index) in str">{{index}}: {{char}}</li>
    </ul>
    <!-- 可以遍历数字 -->
    <ul>
      <li v-for="n in 20">{{n}}</li>
    </ul>

    <ol>
      <li v-for="shop in list">
        <p v-for="(value, key) in shop">{{key}}: {{value}}</p>
      </li>
    </ol>
  </div>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        // 数组响应式更新需要用到数组的api取修改，如果直接修改某一个元素DOM不会响应式更新
        arr: [1,3,4,5,6,7],
        obj: {
          x: 1,
          y: 2,
          z: 30
        },
        str: 'hello vue',
        list: [
          { id: 1, name: '小米', price: 2000},
          { id: 2, name: '华为', price: 6000},
          { id: 3, name: '苹果', price: 8000}
        ]
      }
    })

  </script>
</body>
</html>